<html>
    <head>
    <link rel="stylesheet" href="lmm.css" type="text/css" />
    </head>
<body class="lmm">
<!-- This file is part of the Lisp Machine Manual.  -*-Text-*- -->
<!-- Function Description: Data Type Predicates. > -->
<div class='chapter' id='3'>3. Predicates</div>
<p class='cindent'><!-- "predicate" -->
	A <!-- open: 1, close: 0 --><font class="italic">predicate</font><!-- open: 1, close: 1 --> <!-- MATCHED MATCHED MATCHED --> is a function which tests for some condition involving
its arguments and returns the symbol <!-- open: 2, close: 1 --><font class="lisp">t</font><!-- open: 2, close: 2 --> <!-- MATCHED MATCHED MATCHED --> if the condition is true, or
the symbol <!-- open: 3, close: 2 --><font class="lisp">nil</font><!-- open: 3, close: 3 --> <!-- MATCHED MATCHED MATCHED --> if it is not true.

	By convention, the names of predicates usually end in the letter "p" (which
stands for "predicate").  (See [section on naming conventions]).
<p class='cindent'><!-- "naming convention" -->

	The following predicates are for testing data types.  These predicates
return <!-- open: 4, close: 3 --><font class="lisp">t</font><!-- open: 4, close: 4 --> <!-- MATCHED MATCHED MATCHED --> if the argument is of the type indicated by the name of the function,
<!-- open: 5, close: 4 --><font class="lisp">nil</font><!-- open: 5, close: 5 --> <!-- MATCHED MATCHED MATCHED --> if it is of some other type.
<p class='cindent'><!-- "data-type" -->

<div class='defun' id='symbolp'>
  <font class='exdent'>
    <font class='funcname'>symbolp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "symbol" -->
<!-- open: 6, close: 5 --><font class="lisp">symbolp</font><!-- open: 6, close: 6 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 7, close: 6 --><font class="lisp">t</font><!-- open: 7, close: 7 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a symbol, otherwise <!-- open: 8, close: 7 --><font class="lisp">nil</font><!-- open: 8, close: 8 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='nsymbolp'>
  <font class='exdent'>
    <font class='funcname'>nsymbolp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 9, close: 8 --><font class="lisp">nsymbolp</font><!-- open: 9, close: 9 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 10, close: 9 --><font class="lisp">nil</font><!-- open: 10, close: 10 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a symbol, otherwise <!-- open: 11, close: 10 --><font class="lisp">t</font><!-- open: 11, close: 11 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='listp'>
  <font class='exdent'>
    <font class='funcname'>listp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "cons" -->
<!-- open: 12, close: 11 --><font class="lisp">listp</font><!-- open: 12, close: 12 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 13, close: 12 --><font class="lisp">t</font><!-- open: 13, close: 13 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a cons, otherwise <!-- open: 14, close: 13 --><font class="lisp">nil</font><!-- open: 14, close: 14 --> <!-- MATCHED MATCHED MATCHED -->.
<!-- open: 15, close: 14 --><font class="lisp">(listp nil)</font><!-- open: 15, close: 15 --> <!-- MATCHED MATCHED MATCHED --> is <!-- open: 16, close: 15 --><font class="lisp">nil</font><!-- open: 16, close: 16 --> <!-- MATCHED MATCHED MATCHED --> even though <!-- open: 17, close: 16 --><font class="lisp">nil</font><!-- open: 17, close: 17 --> <!-- MATCHED MATCHED MATCHED --> is the empty list.
</div>

<div class='defun' id='nlistp'>
  <font class='exdent'>
    <font class='funcname'>nlistp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 18, close: 17 --><font class="lisp">nlistp</font><!-- open: 18, close: 18 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 19, close: 18 --><font class="lisp">t</font><!-- open: 19, close: 19 --> <!-- MATCHED MATCHED MATCHED --> if its argument is anything besides a cons,
otherwise <!-- open: 20, close: 19 --><font class="lisp">nil</font><!-- open: 20, close: 20 --> <!-- MATCHED MATCHED MATCHED -->.
This is the recommended predicate for terminating iterations or recursions
on lists.  It is, in fact, identical to <!-- open: 21, close: 20 --><font class="lisp">atom</font><!-- open: 21, close: 21 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='atom'>
  <font class='exdent'>
    <font class='funcname'>atom </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "atom" -->
The predicate <!-- open: 22, close: 21 --><font class="lisp">atom</font><!-- open: 22, close: 22 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 23, close: 22 --><font class="lisp">t</font><!-- open: 23, close: 23 --> <!-- MATCHED MATCHED MATCHED --> if its argument is not a cons,
otherwise <!-- open: 24, close: 23 --><font class="lisp">nil</font><!-- open: 24, close: 24 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='fixp'>
  <font class='exdent'>
    <font class='funcname'>fixp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 25, close: 24 --><font class="lisp">fixp</font><!-- open: 25, close: 25 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 26, close: 25 --><font class="lisp">t</font><!-- open: 26, close: 26 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a fixnum or a bignum, otherwise
<!-- open: 27, close: 26 --><font class="lisp">nil</font><!-- open: 27, close: 27 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='floatp'>
  <font class='exdent'>
    <font class='funcname'>floatp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 28, close: 27 --><font class="lisp">floatp</font><!-- open: 28, close: 28 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 29, close: 28 --><font class="lisp">t</font><!-- open: 29, close: 29 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a flonum or a small flonum,
otherwise <!-- open: 30, close: 29 --><font class="lisp">nil</font><!-- open: 30, close: 30 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='small-floatp'>
  <font class='exdent'>
    <font class='funcname'>small-floatp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 31, close: 30 --><font class="lisp">small-floatp</font><!-- open: 31, close: 31 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 32, close: 31 --><font class="lisp">t</font><!-- open: 32, close: 32 --> <!-- MATCHED MATCHED MATCHED --> if <!-- open: 33, close: 32 --><font class="italic">arg</font><!-- open: 33, close: 33 --> <!-- MATCHED MATCHED MATCHED --> is a small flonum, otherwise <!-- open: 34, close: 33 --><font class="lisp">nil</font><!-- open: 34, close: 34 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='bigp'>
  <font class='exdent'>
    <font class='funcname'>bigp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 35, close: 34 --><font class="lisp">bigp</font><!-- open: 35, close: 35 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 36, close: 35 --><font class="lisp">t</font><!-- open: 36, close: 36 --> <!-- MATCHED MATCHED MATCHED --> if <!-- open: 37, close: 36 --><font class="italic">arg</font><!-- open: 37, close: 37 --> <!-- MATCHED MATCHED MATCHED --> is a bignum, otherwise <!-- open: 38, close: 37 --><font class="lisp">nil</font><!-- open: 38, close: 38 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='numberp'>
  <font class='exdent'>
    <font class='funcname'>numberp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "number" -->
<!-- open: 39, close: 38 --><font class="lisp">numberp</font><!-- open: 39, close: 39 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 40, close: 39 --><font class="lisp">t</font><!-- open: 40, close: 40 --> <!-- MATCHED MATCHED MATCHED --> if its argument is any kind of number,
otherwise <!-- open: 41, close: 40 --><font class="lisp">nil</font><!-- open: 41, close: 41 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='stringp'>
  <font class='exdent'>
    <font class='funcname'>stringp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "string" -->
<!-- open: 42, close: 41 --><font class="lisp">stringp</font><!-- open: 42, close: 42 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 43, close: 42 --><font class="lisp">t</font><!-- open: 43, close: 43 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a string, otherwise <!-- open: 44, close: 43 --><font class="lisp">nil</font><!-- open: 44, close: 44 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='arrayp'>
  <font class='exdent'>
    <font class='funcname'>arrayp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "array" -->
<!-- open: 45, close: 44 --><font class="lisp">arrayp</font><!-- open: 45, close: 45 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 46, close: 45 --><font class="lisp">t</font><!-- open: 46, close: 46 --> <!-- MATCHED MATCHED MATCHED --> if its argument is an array, otherwise <!-- open: 47, close: 46 --><font class="lisp">nil</font><!-- open: 47, close: 47 --> <!-- MATCHED MATCHED MATCHED -->.
Note that strings are arrays.
</div>

<div class='defun' id='subrp'>
  <font class='exdent'>
    <font class='funcname'>subrp </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 48, close: 47 --><font class="lisp">subrp</font><!-- open: 48, close: 48 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 49, close: 48 --><font class="lisp">t</font><!-- open: 49, close: 49 --> <!-- MATCHED MATCHED MATCHED --> if its argument is any compiled code object,
otherwise <!-- open: 50, close: 49 --><font class="lisp">nil</font><!-- open: 50, close: 50 --> <!-- MATCHED MATCHED MATCHED -->.  The Lisp Machine system doesn't use the term "subr",
but the name of this function comes from Maclisp.
</div>

<div class='defun' id='closurep'>
  <font class='exdent'>
    <font class='funcname'>closurep </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "closure" -->
<!-- open: 51, close: 50 --><font class="lisp">closurep</font><!-- open: 51, close: 51 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 52, close: 51 --><font class="lisp">t</font><!-- open: 52, close: 52 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a closure, otherwise <!-- open: 53, close: 52 --><font class="lisp">nil</font><!-- open: 53, close: 53 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='locativep'>
  <font class='exdent'>
    <font class='funcname'>locativep </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<p class='cindent'><!-- "locative" -->
<!-- open: 54, close: 53 --><font class="lisp">locativep</font><!-- open: 54, close: 54 --> <!-- MATCHED MATCHED MATCHED --> returns <!-- open: 55, close: 54 --><font class="lisp">t</font><!-- open: 55, close: 55 --> <!-- MATCHED MATCHED MATCHED --> if its argument is a locative, otherwise <!-- open: 56, close: 55 --><font class="lisp">nil</font><!-- open: 56, close: 56 --> <!-- MATCHED MATCHED MATCHED -->.
</div>

<div class='defun' id='typep'>
  <font class='exdent'>
    <font class='funcname'>typep </font>
    <font class='italic' color='purple'>arg</font>
  </font><br>
<!-- open: 57, close: 56 --><font class="lisp">typep</font><!-- open: 57, close: 57 --> <!-- MATCHED MATCHED MATCHED --> is not really a predicate, but it is explained here because it is
used to determine the datatype of an object.  It returns a symbol describing the
type of its argument, one of the following:
<table>
<tr valign='top'>
<td><font class='lisp'> :symbol</font></td><td>A symbol.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :fixnum</font></td><td>A fixnum.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :flonum</font></td><td>A flonum.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :small-flonum</font></td><td>A small flonum.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :bignum</font></td><td>A bignum.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :list</font></td><td>A cons.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :string</font></td><td>A string.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :array</font></td><td>An array that is not a string.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> :random</font></td><td>Any built-in data type that does not fit into one of the above categories.
</td></tr>
<tr valign='top'>
<td><font class='lisp'> <!-- open: 58, close: 57 --><font class="italic">foo</font><!-- open: 58, close: 58 --> <!-- MATCHED MATCHED MATCHED --></font></td><td>An object of user-defined data-type <!-- open: 59, close: 58 --><font class="italic">foo</font><!-- open: 59, close: 59 --> <!-- MATCHED MATCHED MATCHED --> (any symbol).
See Named Structures, <a href='dfstr.html#named-structure'>this link</a>.
</td></tr><!-- item_ --></table><!-- end table -->


See also <!-- open: 60, close: 59 --><font class="lisp">data-type</font><!-- open: 60, close: 60 --> <!-- MATCHED MATCHED MATCHED -->, <font color='red'>LINK:(</font>data-type-fun).
</div>
<!-- eof -->
</body>
</html>

